		TITLE	CVPUBLIC - Copyright (c) SLR Systems 1994

		INCLUDE	MACROS
		INCLUDE	SYMBOLS
		INCLUDE	MODULES

		PUBLIC	CV_PUBLICS_3


		.DATA

		EXTERNDEF	CV_TEMP_RECORD:BYTE

		EXTERNDEF	CURNMOD_GINDEX:DWORD,BYTES_SO_FAR:DWORD

		EXTERNDEF	MODULE_GARRAY:STD_PTR_S,SYMBOL_GARRAY:STD_PTR_S


		.CODE	PASS2_TEXT

		EXTERNDEF	MOVE_TEXT_TO_OMF:PROC,HANDLE_CV_INDEX:PROC,FLUSH_CV_TEMP:PROC


CV_PUBLICS_3	PROC
		;
		;OUTPUT PUBLIC SYMBOLS FOR CURNMOD
		;
		MOV	EAX,CURNMOD_GINDEX
		PUSHM	EDI,ESI,EBX

		CONVERT	EAX,EAX,MODULE_GARRAY
		ASSUME	EAX:PTR MODULE_STRUCT

		MOV	ESI,[EAX]._M_FIRST_PUB_GINDEX
		MOV	AL,[EAX]._M_FLAGS

		TEST	AL,MASK M_DEBUGGING_THIS	;DO WE WANT THIS MODULE'S STUFF?
		JNZ	PMOD_LOOP
L9$:
		POPM	EBX,ESI,EDI

		RET

PPUB_SKIP:
		MOV	ESI,[ESI].SYMBOL_STRUCT._S_NEXT_SYM_GINDEX
PMOD_LOOP:
		;
		;ONLY WANT INDEX IF THERE IS AT LEAST ONE PUBLIC SYMBOL
		;
		TEST	ESI,ESI
		JZ	L9$			;REAL RARE THAT A MODULE HAS

		CONVERT	ESI,ESI,SYMBOL_GARRAY
		ASSUME	ESI:PTR SYMBOL_STRUCT

		MOV	AL,[ESI]._S_REF_FLAGS
		MOV	ECX,BYTES_SO_FAR

		TEST	AL,MASK S_SPACES
		JNZ	PPUB_SKIP
		;
		;OK, DEFINITELY PUBLICS FROM THIS MODULE
		;
		PUSH	ECX
		MOV	EDI,OFF CV_TEMP_RECORD	;PLACE TO BUILD RECORD

		JMP	PPUB_LOOP_1

NEXT_PPUB_1:
		MOV	ESI,EAX

		TEST	EAX,EAX
		JZ	NEXT_PPUB_2
PPUB_LOOP:
		CONVERT	ESI,ESI,SYMBOL_GARRAY
PPUB_LOOP_1:
		MOV	EAX,[ESI]._S_NEXT_SYM_GINDEX
		MOV	CL,[ESI]._S_REF_FLAGS

		AND	CL,MASK S_SPACES
		JNZ	NEXT_PPUB_1

		MOV	CX,[ESI]._S_CV_TYPE3
		PUSH	EAX

		MOV	EAX,[ESI]._S_OFFSET
		MOV	EBX,[ESI]._S_OS2_NUMBER

		MOV	[EDI+2],BX
		GETT	DL,OUTPUT_SEGMENTED

		OR	DL,DL
		JNZ	L1$

		SHL	EBX,4

		SUB	EAX,EBX
L1$:
		MOV	[EDI],AX
		LEA	ESI,[ESI]._S_NAME_TEXT

		MOV	[EDI+4],CX			;TYPE INDEX
		ADD	EDI,6

		CALL	MOVE_TEXT_TO_OMF

		CMP	EDI,OFF CV_TEMP_RECORD+CV_TEMP_SIZE-SYMBOL_TEXT_SIZE-8
		JNC	PPUB_FLUSH		;CAN WE FIT ANOTHER IF IT IS MAX-SIZE?
NEXT_PPUB:
		POP	ESI			;NEXT SYMBOL, MODULE ORDER

		TEST	ESI,ESI
		JNZ	PPUB_LOOP
NEXT_PPUB_2:
		;
		;FLUSH PARTIAL BUFFER
		;
		CALL	FLUSH_CV_TEMP
		;
		;NOW, DO INDEX ENTRY
		;
		POPM	EAX,EBX,ESI,EDI

		MOV	ECX,102H
		JMP	HANDLE_CV_INDEX

PPUB_FLUSH:
		CALL	FLUSH_CV_TEMP
		JMP	NEXT_PPUB

CV_PUBLICS_3	ENDP


		END

